package org.bringer.service.impl;

import java.util.List;

import javax.jws.WebService;

import org.bringer.dao.AccountDao;
import org.bringer.dao.SearchException;
import org.bringer.model.Account;
import org.bringer.model.User;
import org.bringer.service.AccountManager;
import org.bringer.service.AccountService;
import org.bringer.service.exceptions.AccountExistsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * Implementation of UserManager interface.
 *
 * 
 */
@Service("accountManager")
@WebService(serviceName = "AccountService", endpointInterface = "org.bringer.service.AccountService")
public class AccountManagerImpl extends GenericManagerImpl<Account, Long> implements AccountManager, AccountService {
    
    private AccountDao accountDao;
    @Autowired
	public void setAccountDao(AccountDao accountDao) {
		// TODO Auto-generated method stub
    	  this.dao = accountDao;
          this.accountDao = accountDao;
	}

   
   

	@Override
	public Account getAccountByIban(String ibanCode) {
		// TODO Auto-generated method stub
		return accountDao.getAccountByIban(ibanCode);
	}

	


	@Override
	public Account getAccount(String accountId) {
		// TODO Auto-generated method stub
		return accountDao.get(Long.parseLong(accountId));
	}

	@Override
	public List<Account> getAccountsByUser(String userId)
			throws SearchException {
		User user=new User();
		user.setId(Long.parseLong(userId));
		return accountDao.getAccountsByUser(user);
	}

	@Override
	public List<Account> getAccountsByDescription(String desc)
			throws SearchException {
		// TODO Auto-generated method stub
		return accountDao.getAccountsByDescription(desc);
	}

	@Override
	public Account saveAccount(Account account) throws AccountExistsException {
		// TODO Auto-generated method stub
		return accountDao.save(account);
	}

	@Override
	public void removeAccount(Account account) {
		// TODO Auto-generated method stub
		 accountDao.remove(account);
	}

	@Override
	public void removeAccount(String ibanCode) {
		// TODO Auto-generated method stub
		 accountDao.removeByIban(ibanCode);
	}

	@Override
	public void removeAccount(long id) {
		// TODO Auto-generated method stub
		 accountDao.remove(id);
	}

	@Override
	public List<Account> search(String searchTerm) {
		// TODO Auto-generated method stub
		return null;
	}
}
